<?php

namespace app\index\model;

use think\Model;
use think\model\concern\SoftDelete;

class PhotoCollWork extends Model
{
    use SoftDelete;
    protected $name = 'car_photo_coll_work';
    protected $autoWriteTimestamp = true;
    protected $dateFormat = 'Y/m/d H:i:s';
    protected $createTime = 'create_at';
    protected $updateTime = 'update_at';
    protected $deleteTime='delete_at';

    public function getIsDefaultAttr($value)
    {
        return $value == 1 ? true : false;
    }

    public function coll()
    {
        return $this->hasOne(PhotoColl::class, 'work_id', 'id');
    }

    public function url()
    {
        return $this->hasOne(PhotoColl::class, 'work_id', 'id')->order(
            'create_at',
            'desc'
        )->with('cover')->bind([
            'cover' => 'new_cover'
        ]);
    }
}